V10 Graphics

Yuzhu Lu

User Interface, Wolfram Research, Inc.

What Is New for V10 Graphics?

Texture support for FilledCurve

New Primitives

Inset3D
HalfLine . InfinityLine . HalfPlane . InfinityPlane . ConicHullRegion
Ball . Circumsphere . Simplex . Ellipsoid . Parallelepiped . Triangle . SSSTriangle . SASTriangle . ASATriangle . AASTriangle . Parallelogram

New Options

ClipPlanes . ClipPlanesStyle

Texture Support for FilledCurve

KeyWords: FilledCurve . Texture . VertexTextureCoordinates

How does that work?

You need to provide texture coordinates corresponding to the control points of each segment with VertexTextureCoordinates. There are two way to specify:

Graphics[{Texture[ExampleData[{"ColorTexture","DelisPattern"}]],FilledCurve[{BezierCurve[{{-1,0},{0,1},{1,0}}]},VertexTextureCoordinates->{{-1,0},{0,1},{1,0}}]}]

Graphics[{Texture[ExampleData[{"ColorTexture","DelisPattern"}]],FilledCurve[{BezierCurve[{{-1,0},{0,1},{1,0}},VertexTextureCoordinates->{{-1,0},{0,1},{1,0}}]}]}]

Multi-Segment Object

a={{-1,0},{0,1},{1,0}};b={{0,-(2/3)},{-1,0}};

Graphics[{Texture[ExampleData[{"TestImage","Lena"}]],FilledCurve[{{BezierCurve[2a],Line[2b]},{BezierCurve[a],Line[b]}},VertexTextureCoordinates->{{{0,(1/2)},{(1/2),1},{1,(1/2)},{(1/2),(1/12)},{0,(1/2)}},{{(1/4),(1/2)},{(1/2),(3/4)},{(3/4),(1/2)},{(1/2),(7/24)},{(1/4),(1/2)}}}]}]

Graphics[{Texture[ExampleData[{"TestImage","Lena"}]],FilledCurve[{{BezierCurve[2a,VertexTextureCoordinates->{{0,(1/2)},{(1/2),1},{1,(1/2)}}],Line[2b,VertexTextureCoordinates->{{(1/2),(1/12)},{0,(1/2)}}]},{BezierCurve[a,VertexTextureCoordinates->{{(1/4),(1/2)},{(1/2),(3/4)},{(3/4),(1/2)}}],Line[b,VertexTextureCoordinates->{{(1/2),(7/24)},{(1/4),(1/2)}}]}}]}]

Encoded way used by ImportString and ExportString

FilledCurve[{{{t,n,d},{t,n,d}...}...}, points_array, Method->{...}]:

Graphics[{Texture[ExampleData[{"ColorTexture","DelisPattern"}]],FilledCurve[{{{0,2,1},{1,3,2},{1,2,2},{0,3,1},{1,3,2},{1,2,2}},{{0,3,1}}},{{{2,3},{0.8125,0.625},{0.6875,0.375},{0.375,0.25},{1.125,0.25},{0.8125,0.375},{0.9375,0.625},{1.3125,1.375},{2.4375,1.375},{2.8125,0.625},{2.9375,0.375},{2.625,0.25},{3.625,0.25},{3.3125,0.375},{3.1875,0.625}},{{1.875,2.5},{1.375,1.5},{2.375,1.5}}},VertexTextureCoordinates->{{{2,3},{0.8125,0.625},{0.6875,0.375},{0.375,0.25},{1.125,0.25},{0.8125,0.375},{0.9375,0.625},{1.3125,1.375},{2.4375,1.375},{2.8125,0.625},{2.9375,0.375},{2.625,0.25},{3.625,0.25},{3.3125,0.375},{3.1875,0.625}},{{1.875,2.5},{1.375,1.5},{2.375,1.5}}}]}]

Apply texture to fonts

text=First[First[ImportString[ExportString[Style["Wolfram",Italic,FontSize->24,FontFamily->"Times"],"PDF"],"PDF","TextMode"->"Outlines"]]];

Graphics[{EdgeForm[Black],ColorData["Crayola","Sunglow"],Texture[ExampleData[{"ColorTexture","DelisPattern"}]],text}]/.FilledCurve[a_,b_]:>FilledCurve[a,b, VertexTextureCoordinates->b]

Apply pattern to any thing

You need to convert any graphics into FilledCurves first:

convertedGraphics=First@First@ImportString[ExportString[Graphics[Disk[],ImageSize->20],"PDF"],"PDF","TextMode"->"Outlines"]/.FilledCurve[{{{0,2,0},{0,1,0},{0,1,0}}},{{{0.`,0.`},{20.`,0.`},{20.`,20.`},{0.`,20.`}}}]->{};

Apply the pattern:

Graphics[{EdgeForm[Black],ColorData["Crayola","Sunglow"],Texture[],convertedGraphics}]/.FilledCurve[a_,b_]:>FilledCurve[a,b, VertexTextureCoordinates->b/10]

Apply the pattern to Plot function, new primitives, CountryData, free hand paint, image processing results:

Graphics[{Texture[],First@First@ImportString[ExportString[#,"PDF"],"PDF","TextMode"->"Outlines"]/.{FilledCurve[{{{0,2,0},{0,1,0},{0,1,0}}},{{{0.,0.},{20.,0.},{20.,20.},{0.,20.}}}]->{},EdgeForm[c_]->{}}}]/.FilledCurve[a_,b_]:>FilledCurve[a,b, VertexTextureCoordinates->b/5]&/@{RegionPlot[Xor[x^2+y^2<1,(x-1)^2+y^2<2],{x,-1.5,2.5},{y,-2,2},PlotStyle->Black,BoundaryStyle->None,Frame->False,ImageSize->{20,20}],Graphics[{EdgeForm[Opacity[0]],HalfPlane[{{0,0},{2,1}},{0,1}]},ImageSize->{20,20}],Graphics[{CountryData["Australia","Polygon"]},ImageSize->{20,20}],Graphics[First@,ImageSize->{20,20}],
Show[Image[,ImageSize->{20,20}],Graphics[{Disk@@#&/@ComponentMeasurements[ImageMultiply[,SelectComponents[DeleteBorderComponents[Binarize[,{0,.7}]],{"Area","Holes"},100<#1<1000&&#2>0&]],{"Centroid","EquivalentDiskRadius"}][[All,2]]},ImageSize->{20,20}]]}

Change the pattern:

pattern = Image@Rasterize@Graphics[Line[Table[{{0,a},{1,1+a}},{a,-1,2,0.1}]],PlotRange->{{0,1},{0.5,1.5}},ImageSize->200]

Graphics[{Texture[pattern],First@First@ImportString[ExportString[#,"PDF"],"PDF","TextMode"->"Outlines"]/.{JoinedCurve[{{{0,2,0},{0,1,0},{0,1,0}}},{{{0.,20.},{20.,20.},{20.,0.},{0.,0.}}},op_]->{}}}]/.JoinedCurve[a_,b_,c_]:>FilledCurve[a,b, VertexTextureCoordinates->b/5]&/@{Graphics[[[1]], ImageSize->{20,20}],Graphics[[[1]], ImageSize->{20,20}],Graphics[[[1]], ImageSize->{20,20}]}

Inset3D

KeyWords: Inset

Inset3D provide a way to put 2D graphics/expressions into 3D. The 2D Graphics is always oriented to facing the view point.

Graphics3D[{Opacity[.99],Sphere[{0,-1,0},0.5],Cuboid[{{-0.25,0.5,-0.25},{0.25,1,0.25}}],Inset[Graphics[{Disk[{0,0},.25]},ImageSize->50],{0,0,0}]},PlotRange->2]

Graphics3D[{Opacity[.99],Sphere[{0,-1,0},0.5],Cuboid[{{-0.25,0.5,-0.25},{0.25,1,0.25}}],Inset[Style[HoldForm[(∫_0^∞)(E^(-(x^2)))\[DifferentialD]x],Red,30],{0,0,0}]},PlotRange->2]

Graphics3D[{Opacity[.99],Sphere[{0,-1,0},0.5],Cuboid[{{-0.25,0.5,-0.25},{0.25,1,0.25}}],Inset[DynamicModule[{x=0},Button[Dynamic[x],x++;EmitSound[Sound[SoundNote[]]]]],{0,0,0}]},PlotRange->2]

Application

fire={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
DynamicModule[{b=First@Range[1]},{Graphics3D[{CapForm[None],Tube[BSplineCurve[{{0,0,-1},{0,0,5},{0,0,10},{0,0,17},{0,0,25},{0,0,32},{0,0,35}}],{20,25,26,30,26,20,16}],Inset[Dynamic[Image[fire[[b]],ColorSpace-> "RGB",ImageSize->200]],{0,0,45}]},Boxed->False,ImageSize->{400,400},Lighting->"Neutral"],Dynamic[If[b<31,b++,b=First@Range[1]]]}]

ConicHullRegion

KeyWords: ConicHullRegion . InfiniteLine . HalfLine . InfinitePlane . HalfPlane

ConicHullRegion[{(Subscript[p, 1]),…,(Subscript[p, m+1])}]                               {(Subscript[p, 1])+(Subscript[s, 1]) ((Subscript[p, 2])-(Subscript[p, 1]))+⋯+(Subscript[s, m])((Subscript[p, m+1])-(Subscript[p, 1])) |(Subscript[s, i])∈ℝ}
ConicHullRegion[p,{(Subscript[v, 1]),…,(Subscript[v, m])}]                              {p+(Subscript[s, 1]) (Subscript[v, 1])+⋯+(Subscript[s, m])(Subscript[v, m])|(Subscript[s, i])∈ℝ}
ConicHullRegion[{(Subscript[p, 1]),…,(Subscript[p, m+1])},{(Subscript[w, 1]),…,(Subscript[w, n])}]   {(Subscript[p, 1])+(Subscript[s, 1]) ((Subscript[p, 2])-(Subscript[p, 1]))+⋯+(Subscript[s, m])((Subscript[p, m+1])-(Subscript[p, 1])) +(Subscript[t, 1]) (Subscript[w, 1])+⋯+(Subscript[t, n]) (Subscript[w, n])|(Subscript[s, i])∈ℝ∧(Subscript[t, j])≥0}
ConicHullRegion[p,{(Subscript[v, 1]),…,(Subscript[v, m])},{(Subscript[w, 1]),…,(Subscript[w, n])}]  {p+(Subscript[s, 1]) (Subscript[v, 1])+⋯+(Subscript[s, m])(Subscript[v, m]) +(Subscript[t, 1]) (Subscript[w, 1])+⋯+(Subscript[t, n]) (Subscript[w, n])|(Subscript[s, i])∈ℝ∧(Subscript[t, j])≥0}

ConicHullRegion[{(Subscript[p, 1]),(Subscript[p, 2])}]                                            InfiniteLine[{(Subscript[p, 1]),(Subscript[p, 2])}]
ConicHullRegion[{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}]                                     InfinitePlane[{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}]
ConicHullRegion[{(Subscript[p, 1])},{(Subscript[w, 1])}]                                       HalfLine[(Subscript[p, 1]),(Subscript[w, 1])]
ConicHullRegion[{(Subscript[p, 1]),(Subscript[p, 2])},{(Subscript[w, 1])}]                                InfiniteLine[{(Subscript[p, 1]),(Subscript[p, 2])},(Subscript[w, 1])]

ConicHullRegion[{p},{w1,...,wn}]
ConicHullRegion[p,{},{w1,...,wn}]                 in R^3 with any n>2 is a polyhedral cone.

ConicHullRegion[p,{v},{w1,w2...}]                   in R^3 is an "angle" between two half-planes.

ConicHullRegion[p,{v1,v2},{w1...}]                 in R^3 is a half-space

2D: HalfLine, InfiniteLine, HalfPlane, ConicHullRegion

{Graphics[HalfLine[{0,0},{2,1}],Frame->True],Graphics[InfiniteLine[{0,0},{2,1}],Frame->True],Graphics[HalfPlane[{{0,0},{2,1}},{0,1}],Frame->True]}

Manipulate[Graphics[HalfPlane[{{0,0},{2,b}},{0,1}],Frame->True,ImageSize->{360,360},PlotRange->{{-1,a},{-1,1}}],{{a,1},0,3},{{b,1},-2,2}]

{Graphics[ConicHullRegion[{{0,0}}],Frame->True],Graphics[ConicHullRegion[{{0,0}},{{2,1}}],Frame->True],Graphics[ConicHullRegion[{{0,0},{2,1}}],Frame->True],Graphics[ConicHullRegion[{{0,0},{2,1}},{{1,1}}],Frame->True],Graphics[ConicHullRegion[{{0,0}},{{1,-1},{2,1}}],Frame->True],Graphics[ConicHullRegion[{{0,0}},{{1,-1},{2,1},{1,2}}],Frame->True]}

3D: HalfLine, InfiniteLine, HalfPlane, InfinitePlane and ConicHullRegion

{Graphics3D[HalfLine[{0,0,0},{0,1,0}],Axes->True],Graphics3D[InfiniteLine[{0,0,0},{0,1,0}],Axes->True],Graphics3D[HalfPlane[{{0,0,0},{0,1,0}},{1,-1,-1}],Axes->True],Graphics3D[InfinitePlane[{{0,0,0},{0,1,0},{1,-1,-1}}],Axes->True]}

{Graphics3D[ConicHullRegion[{{0,0,0}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{{0,1,0}}],Axes->True],Graphics3D[ConicHullRegion[{{0,0,0}},{{0,1,0}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{{0,1,0},{1,-1,-1}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{{0,1,0}},{{1,-1,-1}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{},{{-1,-1,-1},{1,-1,-1}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{},{{-1,-1,-1},{1,-1,-1},{1,1,-1},{-1,1,-1}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{{0,1,0}},{{1,0,-1},{1,0,0}}],Axes->True],Graphics3D[ConicHullRegion[{0,0,0},{{0,1,0},{0,0,1}},{{1,0,-1}}],Axes->True]}

More New Primitives

KeyWords: Ball . Circumsphere . Simplex . Ellipsoid . Parallelepiped . Triangle . SSSTriangle . SASTriangle . ASATriangle . AASTriangle . Parallelogram

Ball

Graphics[Ball[2]]

Graphics3D[Ball[3]]

Circumsphere

Graphics[Circumsphere[{{0,0},{1,0},{0,1}}]]

Graphics3D[Circumsphere[{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}]]

Simplex

{Graphics[Simplex[{{0,0}}]],Graphics[Simplex[{{0,0},{2,1}}]],Graphics[Simplex[{{0,0},{1,1},{2,0}}]]}

{Graphics3D[Simplex[{{0,0,1}}]],Graphics3D[Simplex[{{0,0,1},{1,0,0}}]],Graphics3D[Simplex[{{0,0,1},{1,0,0},{1,0,1}}]],Graphics3D[Simplex[{{0,0,1},{1,0,0},{1,0,1},{1,1,1}}]]}

Ellipsoid

Graphics[Ellipsoid[{0,0},{3,2}]]

Graphics3D[Ellipsoid[{0,0,0},{4,3,2}]]

Parallelepiped

{Graphics[Parallelepiped[{0,0},{{2,1}}]],Graphics[Parallelepiped[{0,0},{{1,0},{1,1}}]]}

{Graphics3D[Parallelepiped[{0,0,0},{{1,0,0},{1,1,0}}]],Graphics3D[Parallelepiped[{0,0,0},{{1,0,0},{1,1,0},{0,1,1}}]]}

Triangle

Graphics[Triangle[{{0,0},{1,0},{0,1}}]]

Graphics3D[Triangle[{{0,0,0},{1,0,0},{0,1,1}}]]

SSSTriangle, SASTriangle, ASATriangle, AASTriangle

{Graphics[SSSTriangle[3,4,5]],Graphics[SASTriangle[1,Pi/2,2]],Graphics[ASATriangle[Pi/6,1,Pi/3]],Graphics[AASTriangle[Pi/6,Pi/3,1]]}

Parallelogram

Graphics[Parallelogram[{0,0},{{1,0},{1,1}}]]

{Graphics[{Pink,Parallelogram[{0,0},{{1,0},{1,1}}]}],Graphics[{EdgeForm[Thick],Pink,Parallelogram[{0,0},{{1,0},{1,1}}]}],Graphics[{EdgeForm[Dashed],Pink,Parallelogram[{0,0},{{1,0},{1,1}}]}],Graphics[{EdgeForm[Directive[Thick,Dashed,Blue]],Pink,Parallelogram[{0,0},{{1,0},{1,1}}]}]}

ClipPlanes

KeyWords: ClipPlanes, ClipPlanesStyle

Graphics3D[…,ClipPlanes->{{(Subscript[a, 1]),(Subscript[b, 1]),(Subscript[c, 1]),(Subscript[d, 1])},…}] specifies a list of clipping planes defined as (Subscript[a, n]) x+(Subscript[b, n]) y+(Subscript[c, n]) z+(Subscript[d, n])≤0. The default value is None.

ClipPlanes can specify up to six clipping planes.

ClipPlanesStyles can be used to specify how clipping planes should be rendered.

Graphics3D[{Cylinder[],Red,Cone[{{0,0,-0.99},{0,0,0}},.2]},Axes->True,ClipPlanes->{{1,1,-1,0}}]

Graphics3D[{Cylinder[],Red,Cone[{{0,0,-0.99},{0,0,0}},.2]},Axes->True,ClipPlanes->{{1,1,-1,0}},ClipPlanesStyle->{RGBColor[0,1,0,0.2]}]

Manipulate[Graphics3D[{Cylinder[],Red,Cone[{{0,0,-0.99},{0,0,0}},.2]},Axes->True,ClipPlanes->{{a,b,c,d}},ClipPlanesStyle->{ClipPlaneStyle}],{{a,1},-1,1},{{b,1},-1,1},{{c,-1},-1,1},{{d,0},-3,3},{ClipPlaneStyle,{RGBColor[0,1,0,0.2],None}}]

knee = Raster3D[RawArray["Byte",ImageData[ExampleData[{"TestImage3D","MRknee"}],"Byte"]],{{-1,1,1},{1,-1,-1}},{0,255},ColorFunction->"GrayLevelOpacity"];Manipulate[Graphics3D[knee,ClipPlanes->{{-1,1,-1,d}}],{{d,3},-3,3}]

Improvements / Fixes

PlotRangePadding->All support for Graphics3D

“EdgeDepthOffset” method option for Graphics3D

“ConePoints”, “TubePoints”, “SplinePoints” method options for Graphics3D

Rasterize Graphics3D when exported as pdf (V10.0.2 and after)

...